package unlp_fi.Test_LRS;

import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public abstract class AbstractTest {

	private String endPoint = "http://localhost:8080/LearningRecordStore/";

//	protected String GET = "GET";
//	protected String POST = "POST";

	protected HttpURLConnection connectionGET(String path) {

		URL url;
		HttpURLConnection conn = null;
		try {
			url = new URL(endPoint + path);
			// "http://localhost:8080/LearningRecordStore/actor/get/1");

			conn = (HttpURLConnection) url.openConnection();
			conn.setRequestMethod("GET");
			conn.setRequestProperty("Accept", "application/json");

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return conn;
	}

	
	protected HttpURLConnection connectionPOST(String path) {
		
		URL url;
		HttpURLConnection conn = null;
		try {
			url = new URL(endPoint + path);

			conn = (HttpURLConnection) url.openConnection();
			conn.setRequestMethod("POST");
			conn.setDoOutput(true);

			conn.setRequestProperty("Content-Type", "application/json");

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return conn;
	}

	
}
